import request from '@/utils/request'

// 查询库区列表
export function listArea(query) {
  return request({
    url: '/yyj/wm/warehouse/area/list',
    method: 'get',
    params: query
  })
}

// 查询库区详细
export function getArea(saCode) {
  return request({
    url: '/yyj/wm/warehouse/area/' + saCode,
    method: 'get'
  })
}

// 新增库区
export function addArea(data) {
  return request({
    url: '/yyj/wm/warehouse/area',
    method: 'post',
    data: data
  })
}

// 修改库区
export function updateArea(data) {
  return request({
    url: '/yyj/wm/warehouse/area',
    method: 'put',
    data: data
  })
}

// 删除库区
export function delArea(saCode, slCount) {
  if (slCount.length > 0) {
    return request({
      url: '/yyj/wm/warehouse/area/' + saCode + '/' + slCount,
      method: 'delete'
    })
  } else {
    slCount.push(0)
    return request({
      url: '/yyj/wm/warehouse/area/' + saCode + '/' + slCount,
      method: 'delete'
    })
  }
}

//查询仓库编码
export function selectWCode() {
  return request({
    url: '/yyj/wm/warehouse/manage/list/codes',
    method: 'get'
  })
}
